<template>
	<view class="page">
		<!-- 顶部提示 -->
		<view class="tips1 font12">本处方仅供{{base.pingtai_name}}使用，自行下载配药不具有处方效力</view>
		<!-- 主体内容 -->
		<view class="wrapper">
			<!-- 处方信息 -->
			<view class="tag flex-row-end">
				<text class="font12 font-969696">普通</text>
			</view>
			<view class="hospital font16 font-b tc"><text class="s1">{{info.doctor_info&&info.doctor_info.hospital_name?info.doctor_info.hospital_name:''}}</text><br><text class="s2">处方笺</text></view>
			<view class="part1">
				<view class="item flex-row-start">
					<text class="la">处方号：</text>
					<text class="txt">{{info.code}}</text>
				</view>
				<view class="item flex-row-start">
					<text class="la">开方日期：</text>
					<text class="txt">{{info.createtime}}</text>
				</view>
				<view class="item flex-row-start">
					<text class="la">病历号：</text>
					<text class="txt">{{info.case_code}}</text>
				</view>
				<view class="item flex-row-start">
					<text class="la">医保类型：</text>
					<text class="txt">自费</text>
				</view>
				<view class="item flex-row-start">
					<text class="la">科别：</text>
					<text class="txt">{{info.doctor_info&&info.doctor_info.room_name?info.doctor_info.room_name:''}}</text>
				</view>
				<view class="item flex-row-start">
					<text class="la">姓名：</text>
					<text class="txt">{{info.user_the_patient_info&&info.user_the_patient_info.name?info.user_the_patient_info.name:''}}</text>
					<text class="la label1">性别：</text>
					<text class="txt">{{info.user_the_patient_info&&info.user_the_patient_info.sex?(info.user_the_patient_info.sex == '1' ? '男' : '女'):''}}</text>
					<text class="la label1">年龄：</text>
					<text class="txt">{{info.user_the_patient_info&&info.user_the_patient_info.age?info.user_the_patient_info.age:''}}岁</text>
				</view>
				<view class="item flex-row-start flex-start">
					<view class="label">诊断结果：</view>
					<view class="txt txt-long">{{info.diagnose ? info.diagnose : '暂无'}}</view>
				</view>
			</view>
			<!-- 药品信息 -->
			<view class="part2">
				<p class="title font16 font-b">Rp</p>
				<block v-for="(item, index) in (info.doctor_prescription_access || info.doctor_prescription_list || info.goods_list)" :key="index">
					<view class="item">
						<view class="name flex-row-between"><text>{{item.goods_name}}</text><text>×{{item.number}}</text></view>
						<view class="p">用法用量：{{item.frequencys}}，{{item.consumptions}}，{{item.usages}}</view>
					</view>
				</block>
			</view>
			<!--签名信息 -->
			<view class="part3">
				<!-- 印章图片 -->
				<image class="seal" :src="base.qiniuyun_cdn + base.pharmacist_chapter"></image>
				<view class="title">(以下空白，修改无效)</view>
				<view class="flex-row-between">
					<view class="item u-flex">
						<view class="n1">医师签名：</view>
						<view class="n2">
							<image :src="$base.cdn(info.doctor_info.autograph_img)" mode="widthFix" v-if="info.doctor_info&&info.doctor_info.autograph_img"></image>
						</view>
					</view>
					<!-- <view class="item">
						<text class="n1">配药药师：</text>
						<text class="n2"></text>
					</view> -->
				</view>
				<view class="flex-row-end">
					<view class="item u-flex">
						<view class="n1">复核药师：</view>
						<view class="n2">
							<image :src="$base.cdn(info.pharmacist_info.autograph_img)" mode="widthFix" v-if="info.pharmacist_info&&info.pharmacist_info.autograph_img"></image>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 底部提示 -->
		<view class="tips2 font12">本处方开具3天内有效，仅限{{base.pingtai_name}}使用</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				base: {},
				info: {}
			}
		},
		methods: {
			onLoad: function(options) {
				let $this = this
				let url = ''
				if (options.mode == 'doctor') {
					url = 'detailsPrescription'
				} else if (options.mode == 'ys') {
					url = 'ysDetail'
				} else if (options.mode == 'self') {
					url = 'mydetailsPrescription'
				}
				
				this.$Http({
					url: url,
					data: {doctor_prescription_id: options.id}
				}).then(res => {
					if (res.code == 1) {
						res.data.user_the_patient_info.age = this.$base.Onage(res.data.user_the_patient_info.birthday)
						res.data.createtime = $this.$base.formatTime(new Date(res.data.createtime * 1000), 'yyyy-MM-dd hh:mm:ss')
						$this.info = res.data
					} else {
						uni.showToast({ title: res.msg, icon: 'none' })
					}
				})
				
				// 公共配置
				this.$Http({
					url: 'consultationConsult',
					data: {}
				}).then(res => {
					if (res.code == 1) {
						this.base = res.data
					}
				})
			},
		}
	}
</script>

<style scoped>
	.tips1{width:100%;background-color: #ef9140;line-height: 56rpx;padding: 0 20rpx;color: #fff;position: fixed;top: 0;z-index: 10;}
	.tips2{width:100%;background-color: #ececec;line-height: 56rpx;text-align: center; color: #9997a4;position: fixed;bottom: constant(safe-area-inset-bottom);bottom: env(safe-area-inset-bottom);z-index: 10;}

	.wrapper{padding: 56rpx 20rpx 60rpx;overflow-y: scroll;}
	.tag{padding-top: 20rpx;}
	.tag text{display: block;border: 1rpx solid #dfdcdc;padding: 4rpx 16rpx;line-height: 24rpx;}
	.hospital{padding: 10rpx 0;line-height: 72rpx;}
	.hospital .s2{color: #9997a4;}
	.part1{border-top: 4rpx solid #000;padding: 24rpx 0;}
	.part1 .item{padding: 16rpx 0; font-size: 28rpx;}
	.part1 .la{width: 140rpx;}
	.part1 .label1{margin-left: 40rpx;}
	.part1 .txt{color: #969696;}
	.part1 .txt-long{width: calc(100% - 140rpx);}

	.part2{border-top: 4rpx solid #000;padding: 32rpx 0;}
	.part2 .item{border-bottom: 1rpx solid #dfdcdc;padding: 28rpx 0;font-size: 28rpx;}
	.part2 .p{color: #969696;font-size: 24rpx;}

	.part3{position: relative;}
	.part3 .seal{width: 160rpx;height: 160rpx;position: absolute;right: 16rpx;top: -20rpx;}
	.part3 .title{font-size: 24rpx;padding-bottom: 100rpx;text-align: center;}
	.part3 .item{padding: 40rpx 0;font-size: 28rpx;}
	.part3 .n1{width: 140rpx;min-width: 140rpx;}
	.part3 .n2{width: 300rpx;min-width: 300rpx;}
	.part3 .n2 image{display: block;width: 300rpx;}
</style>
